package com.itheima.tilas.controller;

import com.itheima.tilas.Utils.ResultUtil;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 132
 */
@RestController
@RequestMapping("session")
public class TestSessionController {
    @GetMapping("save")
    public ResultUtil saveSession(HttpSession session){
        session.setAttribute("username","Tom");
        session.setAttribute("password","123456");
        Object username = session.getAttribute("username");
        Object password = session.getAttribute("password");
        List<Object> list = new ArrayList<>();
        list.add(username);
        list.add(password);
        return ResultUtil.success(list);
    }
}
